/*
 * @Description: 
 * @Author: mmzhang
 * @Date: 2022-11-21 10:48:14
 * @LastEditTime: 2022-11-21 15:28:14
 */
import Opt from '@/components/dt/info/Opt.js'
import table from '@/components/dt/table/render.js'
let _this = null,
  sourceWhere = '',
  logtypeSource = ""

class Column extends Opt {
  constructor(vm, source, logtype) {
    console.log(logtype, source, 'visible');
    super()
    _this = vm
    sourceWhere = source
    logtypeSource = logtype
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    let arrColumn = []
    if (sourceWhere.split('_')[0] == 'export') {
      arrColumn = [{
        field: 'operationTime',
        title: '导出时间',
        minWidth: 160,
      },
      {
        field: 'logType',
        title: '导出类型',
        minWidth: 90,
        visible: logtypeSource == 'logtype'

      },
      {
        field: 'content',
        title: '导出内容',
        minWidth: 300,

      }, ]
    } else if (sourceWhere.split('_')[0] == 'operation') {
      arrColumn = [{
        field: 'operationTime',
        title: '操作时间',
        minWidth: 160,
      },
      {
        field: 'logType',
        title: '模块',
        minWidth: 90,
      },
      {
        field: 'content',
        title: '记录内容',
        minWidth: 460,
      }]
    } else if (sourceWhere.split('_')[0] == 'fileDownload') {
      arrColumn = [{
        field: 'operationTime',
        title: '下载时间',
        minWidth: 160,
      },
      {
        field: 'content',
        title: '下载内容',
        minWidth: 460,
      }]
    }
    if(sourceWhere === 'protect') {
      arrColumn = [
        {
          field: 'operationTime',
          title: '操作时间',
        },
        {
          field: 'logType',
          title: '案场类型',
        },
        {
          field: 'componyRange',
          title: '公司范围',
        }, 
        {
          field: 'recordText',
          title: '记录内容',
        }, 
        {
          field: 'opt',
          title: '操作',
        }, 
      ]
    }
    if(sourceWhere === 'rob') {
      arrColumn = [
        {
          field: 'operationTime',
          title: '操作时间',
        },
        {
          field: 'recordText',
          title: '记录内容',
        }, 
      ]
    }

    this.all = [
      {
        field: 'operator',
        title: '操作人',
        minWidth: 100,
        slots: {
          default: (params, h) => {
            return table.cell.text(h, {
              value: `${params.row.operator}(${params.row.workNo})`
            })
          }
        }
      },
      ...arrColumn


    ]
  }

}

export default Column